<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>


<form:form id="sparepartForm" commandName="model" cssClass="validate"
	action="sparepart/sparepart/plan/save">
	<form:hidden path="id" />
	<input type="hidden" id="sourceId" name="sourceId" value="${sourceId }" />
	<input type="hidden" id="ty" name="ty" value="${ty }" />
	<form:hidden path="useStatus" />
	<div class="header">
		<h2>
			&nbsp;&nbsp;备件信息<span><font color="red">（* 为必填项）</font> </span>
		</h2>
	</div>

	<table class=" form-table">
		<tr>
			<td class="td1">编号：</td>
			<td class="td2">${model.code }
			</td>
			<td class="td1">分类：</td>
			<td class="td2"><form:hidden path="sptSparepartCategoryId" /> <isperp:treeSelector
					id="selectParentProjectCategory" url="sparepart/category/getTree"
					valueControlId="sptSparepartCategoryId"
					displayValue="${categoryName}" displayValueCssClass="required"></isperp:treeSelector>
			</td>
		</tr>

		<tr>
			<td class="td1">名称：</td>
			<td class="td2"><form:input path="name" cssClass="required" />
			</td>
			<td class="td1">设备号/PN号：</td>
			<td class="td2"><form:input path="devideNumber"
					cssClass="required" /></td>
		</tr>

		<tr>
			<td class="td1">序列号：</td>
			<td class="td2"><form:input path="sn" cssClass="required"
					cssStyle="" /></td>

			<td class="td1">入库日期：</td>
			<td class="td2"><form:input path="stockInDate" cssClass=""
					cssStyle="" type="date" /></td>
		</tr>
		<tr>
			<td class="td1">责任人：</td>
			<td class="td2"><form:hidden path="useStaffId" /> <isperp:departmentUser 
					displayValue="${model.useStaffName }" valueControlId="useStaffId"
					 idFieldName="name"
					id="useStaffName" ifIncludeNoRoleUser="false" name="useStaffName"
					multiselect="false" displayValueCssClass="required"></isperp:departmentUser>
			</td>

			<td class="td1">使用人：</td>
			<td class="td2"><form:hidden path="supportStaffId" /> <isperp:departmentUser
					displayValue="${model.supportStaffName }"
					valueControlId="supportStaffId" 
					idFieldName="name" id="supportStaffName"
					ifIncludeNoRoleUser="false" name="supportStaffName"
					multiselect="false" displayValueCssClass=""></isperp:departmentUser>
			</td>
		</tr>

		<tr>
			<td class="td1">厂商：</td>
			<td class="td2"><form:input path="manufacturer" cssClass=""
					cssStyle="" /></td>

			<td class="td1">状态：</td>
			<td class="td2"><isperp:dictSelector typeCode="SPAREPART_STATUS"
					name="status" id="status" hasEmptyValue="true"
					dictCssClass="required" selectedValue="${model.status }"></isperp:dictSelector>
			</td>
		</tr>

		<tr>

			<td class="td1">供应商：</td>
			<td class="td2" colspan="3"><form:hidden
					path="manufacturerProviderId" /> <isperp:listSelector
					id="manufacturerProviderName" url="provider/provider/list"
					displayValue="${model.manufacturerProviderName }"
					name="manufacturerProviderName" displayValueCssStyle="width:150px;"
					valueControlId="manufacturerProviderId">
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="code" title="编号" width="80">
					</isperp:column>
					<isperp:column name="name" title="名称" width="150">
					</isperp:column>
					<isperp:column name="linkman" title="联系人" width="80">
					</isperp:column>
					<isperp:column name="linktel" title="联系电话" width="80">
					</isperp:column>
					<isperp:column name="serviceTel" title="客服电话" width="80">
					</isperp:column>
				</isperp:listSelector></td>
		</tr>
		<tr>
			<td class="td1">项目：</td>
			<td class="td2" colspan="3"><form:hidden path="projectName" />
				<form:select path="projectId" items="${projects }" itemLabel="name"
					itemValue="id" cssClass="search"></form:select>
			</td>
		</tr>
		<tr>

			<td class="td1">位置：</td>
			<td class="td2" colspan="3"><form:input path="location"
					cssClass="" cssStyle="width:80%" /></td>

		</tr>


		<tr>
			<td class="td1">备注：</td>
			<td class="td2" colspan="3"><form:textarea path="remark" /></td>
		</tr>

	</table>


</form:form>

<isperp:buttonList>
	<button class="submit"
		onclick="isperp.submitForm({success : function() { isperp.reloadGrid('sparepartGrid');isperp.closeDialog(); }}); return false;">
		<span class="icon icon-save"></span>提交
	</button>
</isperp:buttonList>
<script type="text/javascript">
	function clearCusUser2() {
		$("#supportStaffId").val("");
		$("#cusUserIdSelector2").val("");
	}

	function clearCusUser1() {
		$("#useStaffId").val("");
		$("#cusUserIdSelector1").val("");
	}
	function setCheckedCategoryTreeNodes() {

		var nodes = categoryTree.zTree.getCheckedNodes(true);

		var nStr = "";
		$(nodes).each(function(index, node) {
			nStr += node.id + ",";
		});

		$("#categoryIdValue").val(nStr);
		return true;
	}

	function minStockUseRule_onchange() {

		var minStockUseRuleCheck = $("input[name='minStockUseRule']:checked").val();

		if (minStockUseRuleCheck) {

			$("#isMinStockUseRule").show();
			$("#minStock").hide();
			var treeObj = $.fn.zTree.getZTreeObj("categoryTree");
			treeObj.setting.async.url = "sparepart/sparepart/getConfCategorys?sparepartId=${model.id}";

			categoryTree.reload();

		} else {
			$("#isMinStockUseRule").hide();
			$("#minStock").show();
		}

	}

	$(function() {
		if ('${model.code}' == '') {
			$.ajax({
				url : 'configuration/ci/getSeqByTableName?tableName=spt_sparepart',
				success : function(data) {
					if (data) {
						$("#code").val(data);
					}
				}
			});
		}

		var projectId = '${model.projectId}';
		if (!projectId) {
			$("#projectId").val("");
			$("#projectId").trigger("chosen:updated");
		}

	});

	//minStockUseRule_onchange();
</script>
